package crm.dao.impl;

import crm.Utils.DBUtils;
import crm.Utils.JDBCUtil;
import crm.dao.PlanDao;
import crm.entity.Plan;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class PlanSqlSeverImpl extends JDBCUtil implements PlanDao {


    @Override
    public List<Plan> getByName(String name) {
        String sql = "select * from plan where employee_name=?";
        List<Plan> planList = new ArrayList<Plan>();

        List<Map<String, Object>> maplist = DBUtils.query(sql, name);
        for (Map<String, Object> map : maplist) {
            Plan plan = new Plan();
            plan.setEmployee_name((String) map.get("employee_name"));
            plan.setPlan_id((Integer) map.get("plan_id"));
            plan.setContact_id((Integer) map.get("contact_id"));
            plan.setCustomer_name((String) map.get("customer_name"));
            plan.setPlan_profit((Integer) map.get("plan_profit"));
            plan.setPlan_time((Date) map.get("plan_time"));
            plan.setFinished((Boolean) map.get("IsFinished"));
            plan.setImplementation((String) map.get("implementation"));

            planList.add(plan);
        }
        return planList;
    }
}
